﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2006" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    xmlns:meet="clr-namespace:SiliconStudio.Meet.EjpControls;assembly=EjpControls" 
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    x:Class="ejpClient.Window1" WindowState="Maximized"
    Title="MEET eJournalPlus" Height="700" Width="1000" Closing="OnApplicationClosing"
    
    PreviewMouseMove="OnMagnifierMove"
    >
    <Window.Resources>

        <BooleanToVisibilityConverter x:Key="BoolToVisConverter" />

        <Style TargetType="TabItem">
            <Setter Property="BorderThickness" Value="3"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Border HorizontalAlignment="Stretch" Padding="0,0,2,0" VerticalAlignment="Stretch">
                            <Grid x:Name="_template_TI_RootGrid" AllowDrop="True" >
                                <Grid>
                                    <Border x:Name="TabHeaderBorder" CornerRadius="3,3,0,0" Background="{StaticResource knowledgeMapTabBG}"
                                           BorderBrush="#AA6094D3"
                                           BorderThickness="1">
                                    </Border>
                                </Grid>
                                <Border BorderThickness="0" Padding="4,2,4,2">
                                <ContentPresenter x:Name="Content" ContentSource="Header" Margin="4,2,4,1"
                                         HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                         VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                </Border>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Panel.ZIndex" Value="1"/>
                                <Setter Property="Background" TargetName="TabHeaderBorder" Value="{StaticResource knowledgeMapTabBG_selected}"/>
                            </Trigger>

                            <Trigger Property="Content" Value="{x:Null}">
                                <Setter Property="Panel.ZIndex" Value="1"/>
                                <Setter Property="Background" TargetName="TabHeaderBorder" Value="{StaticResource TabBG_createNew}"/>
                                <Setter Property="Width" TargetName="TabHeaderBorder" Value="30"/>
                            </Trigger>
                            
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Top"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-2,-2,-1"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Bottom"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-1,-2,-2"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Left"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-2,-1,-2"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Right"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-1,-2,-2,-2"/>
                            </MultiTrigger>


                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type ToolTip}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToolTip}">
                        <Grid Name="Border" Background="Transparent" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
                            <Rectangle Stroke="Black" StrokeThickness="0.7">
                                <Rectangle.Fill>
                                    <LinearGradientBrush StartPoint="0.5,0.0708979" EndPoint="0.5,1.2239">
                                        <LinearGradientBrush.GradientStops>
                                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                            <GradientStop Color="#FFCBCBCB" Offset="1"/>
                                        </LinearGradientBrush.GradientStops>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Margin="7,0,7,0" HorizontalAlignment="Left" VerticalAlignment="Top" TextBlock.Foreground="Black" TextBlock.FontSize="11" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate x:Key="StudyListDataTemplate">
            <Grid AllowDrop="True" Tag="{Binding Path=IdString}" Background="{x:Null}"
                  DragEnter="_LB_StudyList_DragOver" Drop="_LB_StudyList_DragOver">
                <Grid.ContextMenu>
                    <ContextMenu Name="dt_mi_ContextMenu" Opened="OnStudyItemContextMenuOpen">
                        <MenuItem Header="スタディを追加" Name="dt_mi_AddStudy" Click="_M_meet_OnAddNewStudy" />
                        <MenuItem Header="スタディ名の変更" Name="dt_mi_RenameStudy" Click="OnRenameStudy" />
                        <MenuItem Header="スタディの削除" Name="dt_mi_DeleteStudy" Click="OnRemoveStudyFromAssignment" /> 
                    </ContextMenu>
                </Grid.ContextMenu>
                
                <Rectangle Fill="{DynamicResource StudyIcon}" x:Name="dt_stBack"/>
                <Rectangle Fill="{DynamicResource StudyIconSelected}" x:Name="dt_stBackSel">
                    
                    <Rectangle.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=IsSelected, 
                                                               RelativeSource={
                                                                    RelativeSource Mode=FindAncestor,
                                                                    AncestorType={x:Type ListBoxItem} }}"
                                             Value="False">
                                    <Setter Property="Rectangle.Visibility" Value="Collapsed" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Rectangle.Style>
                </Rectangle>
                <TextBlock TextWrapping="Wrap" Margin="5,2,5,2" 
                           Padding="0,1,0,0" x:Name="_l_StudyName"
                           Text="{Binding Path=Title}"/>
                
                <TextBox Name="dt_StudyNameTB" Margin="5,-50,5,0" VerticalAlignment="Top"
                           Padding="0,1,0,0" FontSize="9" Text="{Binding Path=Title, Mode=TwoWay}" />
                
            </Grid>
            <DataTemplate.Triggers>
                <EventTrigger SourceName="dt_mi_RenameStudy" RoutedEvent="MenuItem.Click">
                    <BeginStoryboard>
                        <Storyboard Storyboard.TargetName="dt_StudyNameTB" Storyboard.TargetProperty="(FrameworkElement.Margin)">
                            <ThicknessAnimation To="5,2,5,2" Duration="0:0:0.5"/>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <EventTrigger SourceName="dt_StudyNameTB" RoutedEvent="TextBox.LostFocus">
                    <BeginStoryboard>
                        <Storyboard Storyboard.TargetName="dt_StudyNameTB" Storyboard.TargetProperty="(FrameworkElement.Margin)">
                            <ThicknessAnimation To="5,-50,5,0" Duration="0:0:0.5"/>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Fill" Value="{StaticResource StudyIconMouseOver}" TargetName="dt_stBack" />
                </Trigger>
            </DataTemplate.Triggers>
        </DataTemplate>

    </Window.Resources>
    
    <Grid>
    <Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="88"/>
			<ColumnDefinition Width="*"/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="54"/>
			<RowDefinition Height="*"/>
            <RowDefinition Height="30"/>
		</Grid.RowDefinitions>

        
        
        <Rectangle Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                   Fill="{DynamicResource TopStripBGBrush}" />
        <Image Width="153" Height="32" HorizontalAlignment="Left" Margin="70,0,0,7" VerticalAlignment="Bottom" 
               Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Source="pack://application:,,,/imgData/logo_name_0918.png" />

        <Menu x:Name="_m_MainMenu" VerticalAlignment="Top" Height="40" Width="0" HorizontalContentAlignment="Left" 
              VerticalContentAlignment="Center" d:LayoutOverrides="GridBox">
            <MenuItem x:Name="topmenuItem" Width="Auto" Height="Auto" VerticalContentAlignment="Center" Header="" 
                      HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" Padding="13,10,0,10">
                <!--Start new-->
                <MenuItem VerticalContentAlignment="Center" VerticalAlignment="Center" Click="_M_meet_OnStartNewAssignment">
                    <MenuItem.Header>
                        <TextBlock Text="新規作成" VerticalAlignment="Center" />
                    </MenuItem.Header>
                    <MenuItem.Icon>
                        <Image Height="40" Source="pack://application:,,,/imgData/01-assignment_new.png"/>
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                
                <!--Open Assignment-->
                <MenuItem VerticalContentAlignment="Center" Click="_M_meet_OnOpenLocalAssignment">
                    <MenuItem.Header>
                        <TextBlock Text="開く" VerticalAlignment="Center" MouseLeftButtonUp="_M_meet_DefaultOpenCommand" />
                    </MenuItem.Header>
                    <MenuItem.Icon>
                        <Image Height="40" Source="pack://application:,,,/imgData/05-opening.png"/>
                    </MenuItem.Icon>
                    <MenuItem Header="このコンピュータのファイル（ふつうに開く）" Click="_M_meet_OnOpenLocalAssignment"/>
                    <MenuItem Header="このコンピュータのファイル（コメントモードで開く）" IsEnabled="True" x:Name="_menuI_OpenLocalCA" Click="_M_meet_OnOpenLocalCommentedAssignmentEX"/>
                    <MenuItem Header="公開サーバのファイル" IsEnabled="False" x:Name="_menuI_OpenAssignmentOnline" Click="_M_meet_OnOpenEjsAssignment"/>
                </MenuItem>
                <Separator />
                
                <!--Save Assignment-->
                    <MenuItem VerticalContentAlignment="Center" x:Name="_menuI_Save" Click="_M_meet_OnSaveAssignment">
                        <MenuItem.Header>
                            <TextBlock Text="上書き保存" VerticalAlignment="Center" />
                    </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/04-save.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator />
                    <MenuItem VerticalContentAlignment="Center" x:Name="_menuI_SaveAs" Click="_M_meet_OnSaveAssignmentAs">
                        <MenuItem.Header>
                            <TextBlock Text="名前を付けて保存" VerticalAlignment="Center" />
                    </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/04-save.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                <Separator />
                
                <!--Publish-->
                    <MenuItem VerticalContentAlignment="Center" x:Name="_menuI_Publish">
                        <MenuItem.Header>
                            <TextBlock Text="公開" VerticalAlignment="Center" MouseLeftButtonUp="_M_meet_DefaultPublishCommand" />
                    </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/05-opening.png"/>
                        </MenuItem.Icon>
                        <MenuItem x:Name="_menuI_PublishToEJS" Click="_M_meet_OnPublishToEjs">
                            <MenuItem.Header>
                                <TextBlock Text="公開サーバに公開" VerticalAlignment="Center" />
                        </MenuItem.Header>
                            <MenuItem.Icon>
                                <Image Height="40" Source="pack://application:,,,/imgData/05-opening.png"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem IsEnabled="True" x:Name="_menuI_PublishToWLS" Click="_M_meet_OnPublishToWLS">
                            <MenuItem.Header>
                                <TextBlock Text="Live Spaceに公開" VerticalAlignment="Center" />
                        </MenuItem.Header>
                            <MenuItem.Icon>
                                <Image Height="40" Source="pack://application:,,,/imgData/wlp.png"/>
                            </MenuItem.Icon>
                        </MenuItem>
                    </MenuItem>
                    <Separator />
                
                <!--Import Assignments and Media-->
                    <MenuItem VerticalContentAlignment="Center" x:Name="_menuH_Import">
                        <MenuItem.Header>
                            <TextBlock Text="読み込み" MouseLeftButtonUp="_M_meet_DefaultImportCommand" VerticalAlignment="Center" />
                        </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/09-import_assignment.png"/>
                        </MenuItem.Icon>
                        <MenuItem Header="XPSドキュメントの読み込み" Click="_M_meet_OnAddXpsDocumentToStudy"/>
                        <MenuItem IsEnabled="True" Header="このコンピュータのejpファイルの読み込み" Click="_M_meet_OnImportAssignment"/>
                        <MenuItem x:Name="_menuI_MergeFromEjs" IsEnabled="True" 
                                  Header="公開サーバ上のejpファイルの読み込み" Click="_M_meet_OnImportAssignmentFromEjs"/>
                        <MenuItem IsEnabled="True" Header="ナレッジマップのガイドの読み込み" Click="_M_meet_OnSetKnowledgeMapGuide"/>
                        <MenuItem IsEnabled="True" Header="ナレッジマップのガイドの削除" Click="_M_meet_OnClearKnowledgeMapGuide"/>
                        <MenuItem IsEnabled="True" Header="画像ファイルの読み込み" Click="_M_meet_OnImportImage"/>
                    </MenuItem>
                    <Separator />

                <!--Export-->
                    <MenuItem x:Name="_menuH_Export" VerticalContentAlignment="Center">
                        <MenuItem.Header>
                            <TextBlock Text="書き出し" VerticalAlignment="Center" MouseLeftButtonUp="_M_meet_DefaultExportCommand" />
                        </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/08-save_assignment.png"/>
                        </MenuItem.Icon>
                        <MenuItem x:Name="_menuI_ExportReport" IsEnabled="False" Header="レポートの書き出し" Click="_M_meet_OnExportReport"/>
                        <MenuItem x:Name="_menuI_ExportKM" IsEnabled="False" Header="ナレッジマップの書き出し" Click="_M_meet_OnExportKnowledgeMap"/>
                        <!--<MenuItem x:Name="_menuI_Export" Header="アサインメントを書き出す" Click="_M_meet_OnExportAssignment"/>-->
                    </MenuItem>
                    <Separator />

                <!--Printing-->
                    <MenuItem VerticalContentAlignment="Center" x:Name="_menuI_Print">
                        <MenuItem.Header>
                            <TextBlock Text="印刷" VerticalAlignment="Center" MouseLeftButtonUp="_M_meet_DefaultPrintCommand" />
                        </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/10-print.png"/>
                        </MenuItem.Icon>
                        <MenuItem Header="レポートの印刷" Click="_M_meet_OnPrintReport"/>
                        <MenuItem Header="Knowledge Mapの印刷" Click="_M_meet_OnPrintKnowledgeMap" IsEnabled="False" />
                    </MenuItem>
                    <Separator />
                
                <!--Settings-->
                    <MenuItem x:Name="_menuH_Settings" VerticalContentAlignment="Center" Click="_M_meet_OnOpenSettingsWindow">
                        <MenuItem.Header>
                            <TextBlock Text="機能設定" VerticalAlignment="Center" />
                    </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/11-setting.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator />

                    <!--About-->
                    <MenuItem VerticalContentAlignment="Center" VerticalAlignment="Center" Click="_M_meet_OnShowAboutSplash">
                        <MenuItem.Header>
                            <TextBlock Text="このソフトウェアについて" VerticalAlignment="Center" />
                    </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/about.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator />

                    <!--Closing Assignments and Application-->
                    <MenuItem VerticalContentAlignment="Center" x:Name="_menuI_Close">
                        <MenuItem.Header>
                            <TextBlock Text="閉じる" VerticalAlignment="Center" />
                        </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/12-close.png"/>
                        </MenuItem.Icon>
                        <MenuItem x:Name="_menuI_CloseCurrentFile" Header="このファイルを閉じる" Click="_M_meet_OnCloseAssignment"/>
                        <MenuItem Header="eJournalPlusの終了" Click="_M_meet_OnStartQuit"/>
                    </MenuItem>
                    
                
                <!--Study Related-->
                    <!--<MenuItem VerticalContentAlignment="Center" x:Name="_menuH_Study" >
                        <MenuItem.Header>
                            <TextBlock Text="スタディ" VerticalAlignment="Center" />
                        </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/03-study.png"/>
                        </MenuItem.Icon>
                        <MenuItem Header="スタディを追加" Click="_M_meet_OnAddNewStudy"/>
                    </MenuItem>
                    <Separator />
                
                    <MenuItem VerticalContentAlignment="Center" Height="50" HorizontalContentAlignment="Center" Click="_M_meet_OnStartQuit">
                        <MenuItem.Header>
                            <TextBlock Text="終了" VerticalAlignment="Center" />
                        </MenuItem.Header>
                        <MenuItem.Icon>
                            <Image Height="40" Source="pack://application:,,,/imgData/close.png"/>
                        </MenuItem.Icon>
                    </MenuItem>-->
            </MenuItem>
        </Menu>

        <Grid x:Name="_g_MainTabGrid" Grid.Row="1" Margin="0,0,0,0" Grid.Column="0" Grid.ColumnSpan="2">
            <Grid.Background>
                <ImageBrush Stretch="None" TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute" 
                           ImageSource="pack://application:,,,/imgData/bgtile.png" />
            </Grid.Background>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <GridSplitter x:Name="_gS_MainDivider" Margin="0,0,-6,0" Width="12">
                <GridSplitter.Background>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#FFE1E1E1" Offset="0"/>
                        <GradientStop Color="#FF405A7B" Offset="1"/>
                        <GradientStop Color="#FF74A1D8" Offset="0.082"/>
                        <GradientStop Color="#FFE7E7E7" Offset="0.067"/>
                        <GradientStop Color="#FF74A1D8" Offset="0.904"/>
                        <GradientStop Color="#FF73A1D8" Offset="0.913"/>
                    </LinearGradientBrush>
                </GridSplitter.Background>
            </GridSplitter>
            <Grid Margin="8,18,8,8">
                <TabControl x:Name="_tb_XpsDocumentsAndReports" Margin="0,0,4,0" Background="#AA6094D3" 
                            BorderBrush="{x:Null}" IsSynchronizedWithCurrentItem="True">
                </TabControl>
            </Grid>
            <Grid Margin="8,18,8,8" Grid.Column="1">
                <TabControl x:Name="_tb_KnowledgeMaps" SelectionChanged="_km_OnSelectedKmChanged" 
                            Margin="4,0,0,0" Background="#AA6094D3" BorderBrush="{x:Null}" 
                            IsSynchronizedWithCurrentItem="True">
                </TabControl>
            </Grid>
        </Grid>

        <Image MouseLeftButtonUp="Image_MouseLeftButtonUp" Width="81" Height="81" HorizontalAlignment="Left" 
               Margin="-20,-20,0,0" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" 
               Grid.RowSpan="2" Source="pack://application:,,,/imgData/logo_0918.png" />
        
        <!--Main tool Box-->
		<ToolBar x:Name="_meet_MainToolBox" ToolBarTray.IsLocked="True" Margin="140,0,0,1" 
                 Grid.Column="1" HorizontalContentAlignment="Right">
			<ToolBar.Background>
				<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
					<GradientStop Color="#FF58B2F0" Offset="0"/>
					<GradientStop Color="#FFA0CBEA" Offset="1"/>
				</LinearGradientBrush>
			</ToolBar.Background>

                <meet:PenLineButton x:Name="_M_PL_ColorSwatchButton" Margin="4,2,0.3,2" Width="60" Height="41">
                    <meet:PenLineButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">ペン</Label>
                            <Label Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >右の▼ボタンから色を選びます</Label>
                        </StackPanel>
                    </meet:PenLineButton.ToolTip>
                </meet:PenLineButton>
                <meet:MarkerLineButton x:Name="_M_ML_ColorSwatchButton" Margin="0.3,2,0.3,2" Width="60" Height="41">
                    <meet:MarkerLineButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">マーカー</Label>
                            <Label Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >右の▼ボタンから色を選びます</Label>
                        </StackPanel>
                    </meet:MarkerLineButton.ToolTip>
                </meet:MarkerLineButton>
                <Separator />

                <ToggleButton x:Name="_mtb_Eraser" Template="{DynamicResource MTB_eraser}" Margin="0.3,2,0.3,2" 
                          Width="40" Height="41" Checked="_M_da_OnSetInputErase" Unchecked="_M_da_OnUnSetInputErase">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">消しゴム</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >選択中，あるいはこれから選ぶ<LineBreak/>線やオブジェクトを削除します</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
                <Button x:Name="_mtb_Undo" Command="ApplicationCommands.Undo" CommandParameter="{x:Null}"
                    Template="{DynamicResource MB_Undo}" Margin="0.3,2,0.3,2" Width="40" Height="41">
                    <Button.ToolTip>
                       <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">元に戻す</Label>
                    </Button.ToolTip>
                </Button>
                <Button x:Name="_mtb_Redo" Command="ApplicationCommands.Redo" CommandParameter="{x:Null}" 
                    Template="{DynamicResource MB_Redo}" Margin="0.3,2,0.3,2" Width="40" Height="41">
                    <Button.ToolTip>
                        <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">やり直し</Label>
                    </Button.ToolTip>
                </Button>
                <Separator />

      <!--TextBox Tools-->
            <!--TextBox Tool-->
                <ToggleButton x:Name="_mtb_Moji" Template="{DynamicResource MTB_moji}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_da_OnSetModeLabel" Unchecked="_M_km_OnSetMode_None">
                <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">テキストボックス</Label>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            <!--Decrease Font Size-->
                <Button x:Name="_mtb_Moji_S"  Template="{DynamicResource MB_Moji_S}" Margin="0.3,2,0.3,2" Width="40" Height="41" Click="_M_da_OnDecreaseEntityFontSize">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">文字の縮小</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >ナレッジマップの<LineBreak/>文字を小さくします</TextBlock>
                        </StackPanel>
                    </Button.ToolTip>
                </Button>
            <!--Increase Font Size-->
                <Button x:Name="_mtb_Moji_L" Template="{DynamicResource MB_Moji_L}"  Margin="0.3,2,0.3,2" Width="40" Height="41" Click="_M_da_OnIncreaseEntityFontSize">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">文字の拡大</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >ナレッジマップの<LineBreak/>文字を大きくします</TextBlock>
                        </StackPanel>
                    </Button.ToolTip>
                </Button>
                <Separator />
            
        <!--Drawing Tools-->
            <!--FreeHand-->
                <ToggleButton x:Name="_mtb_Curve" Template="{DynamicResource MTB_curve}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_km_OnSetModeFreehand" Unchecked="_M_km_OnSetMode_None">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">フリーハンド</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >自由に線を描きます</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            <!--Line Tool-->
                <ToggleButton x:Name="_mtb_Line" Template="{DynamicResource MTB_line}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_km_OnSetModeLine" Unchecked="_M_km_OnSetMode_None">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">直線</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >直線を描きます</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            <!--Single Arrow Tool-->
                <ToggleButton x:Name="_mtb_SingleArrow" Template="{DynamicResource MTB_single_arrow}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_km_OnSetModeSimpleArrow" Unchecked="_M_km_OnSetMode_None">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">矢印</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >矢印を描きます</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            <!--Double Arrow Tool-->
                <ToggleButton x:Name="_mtb_DoubleArrow" Template="{DynamicResource MTB_double_arrow}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_km_OnSetModeDoubleArrow" Unchecked="_M_km_OnSetMode_None">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">両端矢印</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >両方の終端が矢印の<LineBreak/>線を描きます</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            <!--Square Tool-->
                <ToggleButton x:Name="_mtb_Square" Template="{DynamicResource MTB_square}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_km_OnSetModeSquare" Unchecked="_M_km_OnSetMode_None">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">四角形描画</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >四角形を描きます</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            <!--Circle Tool-->
                <ToggleButton x:Name="_mtb_Circle" Template="{DynamicResource MTB_circle}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_km_OnSetModeCircle" Unchecked="_M_km_OnSetMode_None">
                     <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">だ円描画</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >円またはだ円<LineBreak/>を描きます</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            <!--Note Tool-->
                <ToggleButton x:Name="_mtb_Note" Template="{DynamicResource MTB_note}" Margin="0.3,2,0.3,2" Width="40" Height="41" Checked="_M_km_OnSetModeNote" Unchecked="_M_km_OnSetMode_None">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">自分の意見</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >自分の意見を書くこと<LineBreak/>ができるノード<LineBreak/>を作れます</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
                <Separator />
            
        <!--Meta Tools-->
            <!--Color Swatch-->
                <meet:ColorSwatchButton x:Name="_M_km_ColorSwatchButton" Margin="0.3,2,0.3,2" Width="60" Height="41">
                    <meet:ColorSwatchButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">右の▼ボタンから色を選びます</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >ノードの色はドキュメント<LineBreak/>の線の色と同期します</TextBlock>
                        </StackPanel>
                    </meet:ColorSwatchButton.ToolTip>
                </meet:ColorSwatchButton>
            <!--Lasso Select Tool-->
                <ToggleButton x:Name="_mtb_Select" Template="{DynamicResource MTB_select}" Margin="0.3,2,0.3,2" Width="34" Height="41" Checked="_M_km_OnSetModeSelect" Unchecked="_M_km_OnSetMode_None">
                    <ToggleButton.ToolTip>
                        <StackPanel>
                            <Label Padding="1,5,1,1" FontSize="12" FontWeight="Bold">選択</Label>
                            <TextBlock Margin="5,2,3,0" Padding="1,1,1,5" FontSize="10" >オブジェクトを選択します</TextBlock>
                        </StackPanel>
                    </ToggleButton.ToolTip>
                </ToggleButton>
            </ToolBar>

        <!--Comment Tool Box-->
            <ToolBar IsTabStop="False" x:Name="_meet_CommentToolBox" ToolBarTray.IsLocked="True" Margin="140,-400,0,400" 
                 Grid.Column="1" HorizontalContentAlignment="Right">
                <ToolBar.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFC6F961" Offset="0"/>
                        <GradientStop Color="#FFF3FFDA" Offset="1"/>
                    </LinearGradientBrush>
                </ToolBar.Background>
            </ToolBar>

            <!--StatusBar-->
        <Grid Background="{StaticResource defB_StatusBarBG}" Margin="0" Grid.Row="2" Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.4*"/>
                <ColumnDefinition Width="150"/>
                <ColumnDefinition Width="0.5*"/>
            </Grid.ColumnDefinitions>
            
            <!--Status text label-->
            <TextBlock Margin="15,0,15,0" Grid.Column="0" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="12" Text="Idle" x:Name="_l_AppStatusLabel" />
            
            <!--Application Wide Functions-->
            <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Left">
                <ToggleButton Template="{DynamicResource MB_Magnifier}" x:Name="_tb_MagnifierButton" Padding="0" Width="25" Height="25" /> 
                <Slider ValueChanged="OnMagnifierFactorChanged" x:Name="_sl_MagnifierFactor" Minimum="50" Maximum="300" 
                        Width="50" Value="170" IsDirectionReversed="True" VerticalAlignment="Center" />
                
            </StackPanel>
            
            <!--Study list-->
            <Button Template="{StaticResource MB_ScrollStudyList_left}" x:Name="_ScrollStudyLeft" Grid.Column="2" Width="25" Height="25" Margin="2.5"
                       HorizontalAlignment="Left" VerticalAlignment="Center" Click="OnScrollStudyListLeft" />
            
            <ListBox Margin="30,3,35,3" BorderThickness="0" Grid.Column="2"
                 SelectionChanged="OnSelectedStudyChanged" Grid.Row="2" 
                 ItemTemplate="{DynamicResource StudyListDataTemplate}"
                 IsSynchronizedWithCurrentItem="True"
                 x:Name="_LB_StudyList" LayoutUpdated="_LB_StudyList_LayoutUpdated"
                 ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                 ScrollViewer.CanContentScroll="True"
                 ScrollViewer.VerticalScrollBarVisibility="Disabled">
                <ListBox.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FF58B2F0" Offset="0"/>
                        <GradientStop Color="#FFA0CBEA" Offset="1"/>
                    </LinearGradientBrush>
                </ListBox.Background>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ContextMenu>
                    <ContextMenu Opened="OnStudyListContextMenuOpen">
                        <MenuItem Header="スタディを追加" Name="dt_mi_AddStudy" IsEnabled="False" Click="_M_meet_OnAddNewStudy" />
                    </ContextMenu>
                </ListBox.ContextMenu>
            </ListBox>

            <Button Template="{StaticResource MB_ScrollStudyList_right}" x:Name="_ScrollStudyRight" Grid.Column="2" Width="25" Height="25" Margin="2.5,2.5,7.5,2.5"
                       HorizontalAlignment="Right" VerticalAlignment="Center" Click="OnScrollStudyListRight" />
            
        </Grid>
    </Grid>
    
    <!--Magnifier stuff-->
        <Canvas HorizontalAlignment="Left" VerticalAlignment="Top"> 
            <Canvas Name="mg_bgCanvas" IsHitTestVisible="False"
                    Visibility="{Binding ElementName=_tb_MagnifierButton,Path=IsChecked,Converter={StaticResource BoolToVisConverter}}">
                
                <Rectangle RadiusX="25" RadiusY="25" Width="249" Height="249" Fill="White" />
                <Rectangle Stroke="#FF4161B7" RadiusX="25" RadiusY="25" Width="251" Height="251" 
                           Name="mg_Visual" StrokeThickness="5">
                    <Rectangle.Fill>
                        <VisualBrush ViewboxUnits="Absolute" Viewbox="0,0,50,50"
                         ViewportUnits="RelativeToBoundingBox" Viewport="0,0,1,1"/>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle RadiusX="25" RadiusY="25" Canvas.Left="2" Canvas.Top="2" 
                           StrokeThickness="5" Width="247" Height="247" Stroke="#FF5C7EDA">
                </Rectangle>
            </Canvas>
        </Canvas>
    </Grid>

    
    
    
</Window>
